﻿<%@ Page Language="C#" MasterPageFile="~/Design/MasterPage/MasterPage.master" AutoEventWireup="true"
    CodeFile="MaterialRequisitionForm.aspx.cs" Inherits="App_Master_MaterialRequisitionForm" %>

<%@ Register Assembly="ShpmCommon" Namespace="Shpm.System.Web.Control" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div>

        <script type="text/javascript">

   function change(object)
   {
   window.document.getElementById('<%=employeeName.ClientID%>').value =object.value;
   }
   function popup(id,name)
   {
        window.open('../Commons/EmployeeSearchForm.aspx?CONTROL_ID='+id+"&CONTROL_NAME="+name,'EmployeeSearchForm','scrollbars,resizable')
   }


function countPrice(quantityID)
{
    var quantity = window.document.getElementById(quantityID).value;
    if(quantity=="")
    {
        window.document.getElementById(quantityID).focus();
        alert("申领数不能为空！");
    } 
    else if(quantity.indexOf(".") >= 0)
    {
        window.document.getElementById(quantityID).focus();
        alert("申领数只能输入整数！");
    }
    else if(isNaN(quantity))
    {
        window.document.getElementById(quantityID).focus();
        alert("只能输入数字！");
    }
    else if(quantity < 0)
    {
        window.document.getElementById(quantityID).focus();
        alert("申领数不能小于0！");
    }
}

 /*  function countPrice(quantityID,priceID,countLabID)
   {
    var quantity = window.document.getElementById(quantityID).value;
    var price = window.document.getElementById(priceID).value;
        if( quantity == "" )
        {
            window.document.getElementById(quantityID).value = window.document.getElementById('<%=quantityHid.ClientID%>').value;
            window.document.getElementById(quantityID).focus();
			alert("申领数或单价不能为空！");	
        }
        else if( quantity.indexOf(".") >= 0 ){
            window.document.getElementById(quantityID).value = window.document.getElementById('<%=quantityHid.ClientID%>').value;
            window.document.getElementById(quantityID).focus();
			alert("申领数只能输入整数！");	
		}
		else if( isNaN(quantity) || isNaN(price)){
		    window.document.getElementById(quantityID).value = window.document.getElementById('<%=quantityHid.ClientID%>').value;
		    window.document.getElementById(quantityID).focus();
			alert("只能输入数字！");	

		}
		else if( quantity < 0 ){
		    window.document.getElementById(quantityID).value = window.document.getElementById('<%=quantityHid.ClientID%>').value;
		    window.document.getElementById(quantityID).focus();
			alert("申领数或单价不能小于0！");
		}
		else if(  price == "")
        {
            window.document.getElementById(priceID).value = window.document.getElementById('<%=priceHid.ClientID%>').value;
            window.document.getElementById(priceID).focus();

			alert("单价不能为空！");	
        }
		else if(  isNaN(price)){
		    window.document.getElementById(priceID).value = window.document.getElementById('<%=priceHid.ClientID%>').value;
		     window.document.getElementById(priceID).focus();
			alert("单价只能输入数字！");	

		}
		else if( price < 0){
		    window.document.getElementById(priceID).value = window.document.getElementById('<%=priceHid.ClientID%>').value;
		     window.document.getElementById(priceID).focus();
			alert("单价不能小于0！");
		}
		else
		{
		   window.document.getElementById(countLabID).innerHTML = (quantity*price).toFixed(2);
		}
		
   }
   
   //临时数据保存
   function tempDate(quantityID,priceID)
   {
       var quantity = window.document.getElementById(quantityID).value;
       var price = window.document.getElementById(priceID).value;
       
       window.document.getElementById('<%=quantityHid.ClientID%>').value =quantity;
       window.document.getElementById('<%=priceHid.ClientID%>').value  =price;

   }*/
        </script>

        <table class="table_border_line">
            <tr>
                <td align="left" colspan="4" style="height: 17px">

                    <script language="javascript">
                                (new TitleBar('RegisterBar', '检索条件')).showBar();
                    </script>

                </td>
            </tr>
        </table>
        <table width="40%">
            <tr>
                <td style="width: 89px; height: 24px;">
                </td>
                <td align="left" style="height: 24px; width: 285px;">
                    物品类别：
                    <asp:DropDownList ID="catalogDrop" runat="server" EnableTheming="False" DataTextField="MaterialName"
                        DataValueField="MaterialId" Width="89px">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td style="width: 89px; height: 24px;">
                </td>
                <td align="left" style="height: 24px; width: 285px;">
                    物品名称：
                    <asp:TextBox ID="materialName" runat="server" Width="143px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="height: 45px" align="center" colspan="2" valign="middle">
                    <asp:Button ID="search" runat="server" Text="检 索" Width="81px" CssClass="button"
                        OnClick="search_Click" />
                </td>
            </tr>
            <tr>
                <td align="center" colspan="2" valign="top">
                    <asp:GridView ID="GridView1" runat="server" CssClass="GridView_table" AutoGenerateColumns="False"
                        AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging" OnRowEditing="GridView1_OnRowEditing">
                        <Columns>
                            <asp:BoundField HeaderText="类别" DataField="CatalogName">
                                <ItemStyle CssClass="GridView_item_center" Width="40%" />
                                <HeaderStyle CssClass="GridView_head_grayblue" />
                            </asp:BoundField>
                            <asp:BoundField HeaderText="名称" DataField="MaterialName">
                                <ItemStyle CssClass="GridView_item_center" Width="40%" />
                                <HeaderStyle CssClass="GridView_head_grayblue" />
                            </asp:BoundField>
                            <asp:CommandField HeaderText="加入清单" ShowEditButton="True" ButtonType="Image" EditImageUrl="~/images/edit.jpg">
                                <HeaderStyle CssClass="GridView_head_grayblue" Width="20%" />
                                <ItemStyle CssClass="GridView_item_center" />
                            </asp:CommandField>
                            <asp:TemplateField Visible="False">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("MaterialId") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemStyle CssClass="GridView_item_center" />
                                <HeaderStyle CssClass="GridView_head_grayblue" />
                                <ItemTemplate>
                                    <asp:Label ID="materialId" runat="server" Text='<%# Bind("MaterialId") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <PagerStyle HorizontalAlign="Right" />
                    </asp:GridView>
                </td>
            </tr>
        </table>
        <table class="table_border_line">
            <tr>
                <td align="center" style="height: 17px">

                    <script language="javascript">
                                (new TitleBar('RegisterBar', '申领单')).showBar();
                    </script>

                </td>
            </tr>
        </table>
        <cc1:ComValidator ID="ComValidator1" runat="server" CheckItems-Capacity="4" Visible="False">
            <cc1:CheckRequiredAttribute Code="E0082" ControlToValidator="txtEmpAudId">
                <cc1:ComAbsParamsAttribute Parameter="审批人" />
            </cc1:CheckRequiredAttribute>
            <cc1:CheckRequiredAttribute Code="E0082" ControlToValidator="requisitionDateText">
                <cc1:ComAbsParamsAttribute Parameter="申领日期" />
            </cc1:CheckRequiredAttribute>
            <cc1:CheckDateAttribute Code="E0034" ControlToValidator="requisitionDateText" DataFormat="yyyy/mm/dd">
                <cc1:ComAbsParamsAttribute Parameter="申领日期" />
            </cc1:CheckDateAttribute>
            <cc1:CheckRequiredAttribute Code="E0082" ControlToValidator="RequisitionMemoText">
                <cc1:ComAbsParamsAttribute Parameter="申领原因" />
            </cc1:CheckRequiredAttribute>
        </cc1:ComValidator>
        <table>
            <tr>
                <td style="width: 311px" valign="top">
                    <table>
                        <tr>
                            <td style="width: 268px; height: 26px;" align="right">
                                <span style="color: #ff7300">*</span></td>
                            <td style="height: 26px; width: 395px;">
                                &nbsp; &nbsp; 申领人：<asp:Label ID="labEmpResName" runat="server" Text="Label"></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 268px; height: 26px;" align="right">
                                <span style="color: #ff7300">*</span></td>
                            <td style="height: 26px; width: 395px;">
                                &nbsp; &nbsp; 审批人：<asp:TextBox ID="txtEmpAudId" runat="server" Width="47px"></asp:TextBox>
                                <asp:TextBox ID="txtEmpAudName" runat="server" Width="63px" ReadOnly="True" BackColor="#E0E0E0"
                                    BorderColor="#E0E0E0" Font-Bold="False" onpropertychange="change(this);"></asp:TextBox>
                                <a href="#" onclick="javascript:popup('<%=txtEmpAudId.ClientID%>','<%=txtEmpAudName.ClientID%>');">
                                    <img id="Img1" runat="server" src="../../images/search.jpg" border="0" />
                                </a>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 268px; height: 26px;" align="right">
                                <span style="color: #ff7300">*</span></td>
                            <td style="width: 395px; height: 26px;">
                                申领日期：<asp:TextBox ID="requisitionDateText" runat="server" onfocus="new Calendar().show(this);"
                                    Width="112px"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 268px; height: 28px;" align="right">
                                <span style="color: #ff7300">*</span></td>
                            <td style="width: 395px; height: 28px;">
                                申领原因：
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 268px; height: 85px;">
                            </td>
                            <td style="width: 395px; height: 85px;">
                                <asp:TextBox ID="RequisitionMemoText" runat="server" Height="83px" TextMode="MultiLine"
                                    Width="221px"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 268px; height: 73px">
                            </td>
                            <td style="width: 395px; height: 73px">
                                <asp:Button ID="insert" runat="server" Text="新 建" Width="76px" CssClass="button"
                                    OnClick="insert_Click" />
                                <asp:Button ID="save" runat="server" Text="登 记" Width="76px" CssClass="button" OnClick="save_Click"
                                    OnClientClick="return confirm('是否登入数据？')" />
                                <asp:Button ID="clear" runat="server" Text="清空清单" Width="73px" CssClass="button"
                                    OnClick="clear_Click" OnClientClick="return confirm('是否清空数据？')" />
                            </td>
                        </tr>
                    </table>
                </td>
                <td align="left" valign="top">
                    <asp:GridView ID="GridView2" runat="server" CssClass="GridView_table" AutoGenerateColumns="False"
                        OnRowDataBound="GridView2_RowDataBound" OnRowDeleting="GridView2_OnRowDeleting"
                        OnPageIndexChanging="GridView2_PageIndexChanging" Width="551px" BorderWidth="0px">
                        <Columns>
                            <asp:BoundField HeaderText="类别" DataField="CatalogName">
                                <ItemStyle CssClass="GridView_item_center" Width="30%" />
                                <HeaderStyle CssClass="GridView_head_grayblue" />
                            </asp:BoundField>
                            <asp:BoundField HeaderText="名称" DataField="MaterialName">
                                <ItemStyle CssClass="GridView_item_center" Width="30%" />
                                <HeaderStyle CssClass="GridView_head_grayblue" />
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="数量">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    &nbsp;<asp:TextBox ID="quantity" runat="server" Width="43px" MaxLength="5"></asp:TextBox>
                                </ItemTemplate>
                                <ItemStyle CssClass="GridView_item_center" Width="10%" />
                                <HeaderStyle CssClass="GridView_head_grayblue" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="单价" Visible="false">
                                <ItemStyle CssClass="GridView_item_center" Width="10%" />
                                <HeaderStyle CssClass="GridView_head_grayblue" Width="10%" />
                                <ItemTemplate>
                                    <asp:TextBox ID="price" runat="server" Width="66px" MaxLength="7"></asp:TextBox>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="合计" Visible="false">
                                <HeaderStyle CssClass="GridView_head_grayblue" />
                                <ItemStyle CssClass="GridView_item_center" Width="10%" />
                                <ItemTemplate>
                                    <asp:Label ID="count" runat="server" Text=""></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="删除" ShowHeader="False">
                                <ItemStyle CssClass="GridView_item_center" />
                                <HeaderStyle CssClass="GridView_head_grayblue" Width="10%" />
                                <ItemTemplate>
                                    <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False" CommandName="Delete"
                                        ImageUrl="~/images/delete.jpg" Text="" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField Visible="False">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("MaterialId") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemStyle CssClass="GridView_item_center" />
                                <HeaderStyle CssClass="GridView_head_grayblue" />
                                <ItemTemplate>
                                    <asp:Label ID="materialId" runat="server" Text='<%# Bind("MaterialId") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <PagerStyle HorizontalAlign="Right" VerticalAlign="Middle" />
                        <EmptyDataTemplate>
                            <table class="GridView_table" cellspacing="0" id="GridView2_EmptyDataTemplate" border="0">
                                <tr>
                                    <th class="GridView_head_grayblue" scope="col" style="width: 30%;">
                                        类别</th>
                                    <th class="GridView_head_grayblue" scope="col" style="width: 30%;">
                                        名称</th>
                                    <th class="GridView_head_grayblue" scope="col" style="width: 10%;">
                                        数量</th>
                                    <th class="GridView_head_grayblue" scope="col" style="width: 10%; display: none">
                                        单价</th>
                                    <th class="GridView_head_grayblue" scope="col" style="width: 10%; display: none">
                                        合计</th>
                                    <th class="GridView_head_grayblue" scope="col" style="width: 10%;">
                                        删除</th>
                                </tr>
                            </table>
                        </EmptyDataTemplate>
                    </asp:GridView>
                </td>
            </tr>
            <tr>
                <td align="center" colspan="2" style="height: 10px">
                </td>
            </tr>
        </table>
        <asp:HiddenField ID="quantityHid" runat="server" />
        <asp:HiddenField ID="priceHid" runat="server" />
        <asp:HiddenField ID="employeeName" runat="server" />
        <table class="table_border_line">
            <tr>
                <td align="left" colspan="4">

                    <script language="javascript" type="text/javascript">
                                (new TitleBar('RegisterBar', '申领单列表')).showBar();
                    </script>

                </td>
            </tr>
        </table>
        <table width="80%">
            <tr>
                <td colspan="2" style="height: 174px" valign="top">
                    <asp:GridView ID="GridView3" runat="server" CssClass="GridView_table" AutoGenerateColumns="False"
                        OnRowDataBound="GridView3_RowDataBound" BorderWidth="0px" AllowPaging="True"
                        OnRowEditing="GridView3_OnRowEditing" OnRowDeleting="GridView3_OnRowDeleting"
                        OnPageIndexChanging="GridView3_PageIndexChanging">
                        <Columns>
                            <asp:BoundField HeaderText="申领日期" DataField="RequisitionDate" DataFormatString="{0:yyyy/MM/dd}"
                                HtmlEncode="False">
                                <ItemStyle CssClass="GridView_item_center" Width="10%" />
                                <HeaderStyle CssClass="GridView_head_grayblue" />
                            </asp:BoundField>
                            <asp:BoundField HeaderText="申领原因" DataField="RequisitionMemo">
                                <ItemStyle CssClass="GridView_item_center" Width="40%" />
                                <HeaderStyle CssClass="GridView_head_grayblue" />
                            </asp:BoundField>
                            <asp:BoundField HeaderText="申领人" DataField="RequisitionPersonName">
                                <ItemStyle CssClass="GridView_item_center" Width="10%" />
                                <HeaderStyle CssClass="GridView_head_grayblue" />
                            </asp:BoundField>
                            <asp:BoundField HeaderText="申领部门" DataField="RequisitionDeptmentName">
                                <ItemStyle CssClass="GridView_item_center" Width="10%" />
                                <HeaderStyle CssClass="GridView_head_grayblue" />
                            </asp:BoundField>
                            <asp:BoundField HeaderText="审批状态" DataField="AuditingTypeName">
                                <ItemStyle CssClass="GridView_item_center" Width="10%" />
                                <HeaderStyle CssClass="GridView_head_grayblue" />
                            </asp:BoundField>
                            <asp:BoundField HeaderText="审批日期" DataField="AuditingDate" DataFormatString="{0:yyyy/MM/dd}"
                                HtmlEncode="False">
                                <ItemStyle CssClass="GridView_item_center" Width="10%" />
                                <HeaderStyle CssClass="GridView_head_grayblue" />
                            </asp:BoundField>
                            <asp:CommandField HeaderText="编辑" ShowEditButton="True" ButtonType="Image" EditImageUrl="~/images/edit.jpg">
                                <HeaderStyle CssClass="GridView_head_grayblue" Width="5%" />
                                <ItemStyle CssClass="GridView_item_center" />
                            </asp:CommandField>
                            <asp:TemplateField HeaderText="删除" ShowHeader="False">
                                <ItemStyle CssClass="GridView_item_center" />
                                <HeaderStyle CssClass="GridView_head_grayblue" Width="5%" />
                                <ItemTemplate>
                                    <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False" CommandName="Delete"
                                        ImageUrl="~/images/delete.jpg" Text="" OnClientClick="return confirm('确定删除吗？')" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="申领单id" Visible="False">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("RequisitiobnId") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemStyle CssClass="GridView_item_center" />
                                <HeaderStyle CssClass="GridView_head_grayblue" />
                                <ItemTemplate>
                                    <asp:Label ID="requisitiobnId" runat="server" Text='<%# Bind("RequisitiobnId") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <PagerStyle HorizontalAlign="Right" />
                        <EmptyDataTemplate>
                            <table class="GridView_table" cellspacing="0" rules="all" id="GridView3_EmptyDataTemplate"
                                border="0">
                                <tr>
                                    <th class="GridView_head_grayblue" scope="col" style="width: 10%;">
                                        申领日期</th>
                                    <th class="GridView_head_grayblue" scope="col" style="width: 40%;">
                                        申领原因</th>
                                    <th class="GridView_head_grayblue" scope="col" style="width: 10%;">
                                        申领人</th>
                                    <th class="GridView_head_grayblue" scope="col" style="width: 10%;">
                                        申领部门</th>
                                    <th class="GridView_head_grayblue" scope="col" style="width: 10%;">
                                        审批状态</th>
                                    <th class="GridView_head_grayblue" scope="col" style="width: 10%;">
                                        审批日期</th>
                                    <th class="GridView_head_grayblue" scope="col" style="width: 5%;">
                                        编辑</th>
                                    <th class="GridView_head_grayblue" scope="col" style="width: 5%;">
                                        删除</th>
                                </tr>
                            </table>
                        </EmptyDataTemplate>
                    </asp:GridView>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
